package me.xplabs.model.proxy 
{
	import com.greensock.events.LoaderEvent;
	import flash.utils.ByteArray;
	import flash.utils.getQualifiedClassName;
	import me.xplabs.Globals;
	import me.xplabs.constant.ResType;
	import me.xplabs.model.GameDataSingleton;
	import me.xplabs.msg.NotificationName;
	import me.xplabs.ui.baseui.Alert;
	import org.puremvc.as3.patterns.proxy.Proxy;
	
	/**
	 * ...
	 * @author xiaohan
	 */
	public class LoaderMapProxy extends Proxy
	{
		public static var NAME:String;
		private var _mapkey:String;
		private var _energyKey:String;
		private var _raidId:int;
		private var _isLoadering:Boolean;
		public function LoaderMapProxy() 
		{
			NAME = getQualifiedClassName(this);
			super(NAME, null);
			
		}
		private function onComplete(e:LoaderEvent):void 
		{
			var data:* = Globals.lib.getResObj(_mapkey);
			if (!data) 
			{
				Alert.show("此关卡暂未开放！！", 1);
				return;
			}
			data.inflate();
			data.position = 0;
			sendNotification(NotificationName.LOADER_MAP_COMPLETE, {data:data,raidId:_raidId}, NotificationName.LOADER_MAP_COMPLETE);
			//sendNotification(NotificationName.LOADER_MAP_COMPLETE,  Globals.lib.getResObj(_energyKey), NotificationName.LOADER_ENERGY_COMPLETE);
			_isLoadering = false;
			GameDataSingleton.i.raidId = _raidId;
			
		}

		public function setMapData(p_id:int):void
		{
			if (_isLoadering) return;
			_isLoadering = true;
			_raidId = p_id;
			_mapkey = Globals.domain.format(Globals.domain.map + p_id, ResType.T_MAP);
			_energyKey = Globals.domain.format(Globals.domain.map + p_id, ResType.T_XML);
			Globals.lib.parse( [_mapkey, _energyKey,
								Globals.domain.format(Globals.domain.role + 1, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 2, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 3, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 4, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 5, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 6, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 7, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 8, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 9, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 10, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 11, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 12, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 13, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 14, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 15, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 16, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 17, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 18, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 19, ResType.T_SWF),
								Globals.domain.format(Globals.domain.role + 20, ResType.T_SWF),
								/*Globals.domain.format(Globals.domain.build + "i999", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1000", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1001", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1002", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1003", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1004", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1005", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1011", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1012", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1013", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1014", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1015", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1021", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1022", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1023", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1024", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1025", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1031", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1032", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1033", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1034", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "i1035", ResType.T_SWF),*/
								Globals.domain.format(Globals.domain.build + "r999", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1001", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1002", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1003", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1004", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1005", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1011", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1012", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1013", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1014", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1015", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1021", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1022", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1023", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1024", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1025", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1031", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1032", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1033", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1034", ResType.T_SWF),
								Globals.domain.format(Globals.domain.build + "r1035", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r1", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r2", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r3", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r5", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r6", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r7", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r8", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100011_2", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100101_2", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100201_2", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100012_2", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100012_3", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100013_2", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100013_3", ResType.T_SWF),
								Globals.domain.format(Globals.domain.magic + "r100010_2", ResType.T_SWF)
								], { onComplete:onComplete } );
		}
	}

}